/* vector 交换的妙用 */
#include <vector>
#include <iostream>

using namespace std;
void my_print(vector<int> &v);
int main(int argc, char **argv)
{
    vector<int> v;
    v.reserve(10000);
    v.resize(10);

    cout << v.capacity() << endl;
    cout << v.size() << endl;


    /* 交换 */

    /* 匿名对象不可以引用 ,但是加const可以引用*/
    //v.swap(vector<int>(v));
    //const vector<int> &ob = vector<int>(v);
    vector<int>(v).swap(v);
    

    cout << v.capacity() << endl;
    cout << v.size() << endl;

    return 0;
}

void my_print(vector<int> &v)
{
    vector<int>::iterator it = v.begin();

    for (; it != v.end(); it++)
    {

        cout << *it << " ";
    }

    cout << endl;

    return;
}